using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

namespace Imagination.Physics
{
    public struct Force
    {
		public Vector3? Value
		{
			get
			{
				if (mass.HasValue)
					return Mass.Value * acceleration;
				else
					return null;
			}
		}

		public bool IsField;
		public Thing SourceOfMass;
		private Vector3 acceleration;
		private float? mass;

		public bool IsTemporary;

		public Vector3 Acceleration
		{
			get { return acceleration; }
			set { acceleration = value; }
		}

		public float? Mass
		{
			get
			{
				if (SourceOfMass != null)
					return SourceOfMass.Mass;
				else
					return mass;
			}
			set
			{
				mass = value;
			}
		}

		public Force(float x, float y, float z, Thing sourceOfMass)
        {
            IsField = false;
			acceleration = new Vector3(x, y, z);
			SourceOfMass = sourceOfMass;
			mass = 0f;
			IsTemporary = false;
		}

		public Force(Vector3 acceleration, Thing sourceOfMass)
        {
            this.acceleration = acceleration;
			mass = 0f;
            IsField = false;
			SourceOfMass = sourceOfMass;
			IsTemporary = false;
		}

		public Force(Vector3 acceleration)
		{
			this.acceleration = acceleration;
			IsField = true;
			SourceOfMass = null;
			mass = null;
			IsTemporary = false;
		}
    }
}
